﻿#include "EasyMsg.h"
#include "EasyMsgEventHandler.h"
#include <QEvent>
#include <QCoreApplication>
namespace EM {

EasyMsg::EasyMsg()
{
}

EasyMsg::~EasyMsg()
{

}
void pushMsg(EasyMsg *msg)
{
    EasyMsgImp::EasyMsgDispatcher::Instance()->dispatch(msg);
}

void postMsg(EasyMsg *msg)
{
    QEvent * event = new EasyMsgImp::MsgArrivedEvent(msg);
    QCoreApplication::postEvent(EasyMsgImp::EasyMsgDispatcher::Instance()->eventHandler(), event);
}


void unsubscript(void *hostObj)
{
    EasyMsgImp::EasyMsgDispatcher::Instance()->removeCallback(hostObj);
}

void unsubscript(QString msgId, void *hostObj)
{
    EasyMsgImp::EasyMsgDispatcher::Instance()->removeCallback(msgId, hostObj);
}






}
